<div class="contents">
  <ol class="breadcrumb">
    <li><a href="#/index/panel">首页</a></li>
    <li><a href="#/million/list">活动商品列表</a></li>
    <li class="active">{{ id ? "编辑":"新增"}}活动商品</li>
  </ol>

  <div class="row">
    <div class="text-danger" ng-show=" (100 * activityProduct.amount) > (product.pMinimumAmount * minRebate)">奖励金额已经超过了最低返佣金额(最低返佣率:{{minRebate | profitRender}},起购金额:{{product.pMinimumAmount | moneyRender}},最低返佣金额:{{product.pMinimumAmount * minRebate / 100}})</div>

    <div ng-if="id">
      <label class="col-sm-2 control-label">产品名称：{{product.pName}}</label>
    </div> 
  </div>

  <form class="form-inline search-box" role="form" name="form" ng-submit="addActivityProduct()" novalidate>
    <span class="label label-primary" style="margin-left: 2px; padding-top: 5px;">添加产品</span><br>

    <div class="form-group">
      <label class="sr-only">活动名称</label>
      <select class="form-control" name="activitiesCode" ng-model="activityProduct.activitiesCode" ng-options="m.activitiesCode as m.activitiesName for m in activityList" ng-change="changeActivity()" required="required">
        <option value="">--选择活动--</option>
      </select>
    </div>

    <div class="form-group">
      <label class="sr-only">产品类别</label>
      <select class="form-control" ng-model="activityProduct.pType" ng-options="m.value as m.text for m in productTypeModel">
        <option value="">--选择产品类别--</option>
      </select>
    </div>
    
    <div class="form-group">
      <label class="sr-only" >产品名称</label>
      <input type="text" class="form-control" placeholder="产品名称" ng-model="activityProduct.productName">
    </div>

    <div class="form-group" style="width: 300px;">
      <label class="sr-only">选择产品</label>
      
      <select class="form-control" ng-if="activityProduct.pType != '01'" ng-model="activityProduct.pId" ng-options="p.id as p.pName for p in activityProduct.productList | filter:activityProduct.productName" style="width: 100%;">
        <option value="">--选择选择产品--</option>
      </select>

      <select class="form-control" ng-if="activityProduct.pType == '01'" ng-model="activityProduct.pId" ng-options="p.id as p.jjmc for p in activityProduct.productList | filter:activityProduct.productName" style="width: 100%;">
        <option value="">--选择选择产品--</option>
      </select>
    </div>

    <div class="form-group" ng-class="{'has-error':form.activitiesProductType.$invalid}" ng-if="activityProduct.activitiesCode == 'BWCSY' || activityProduct.activitiesCode == 'ZXLCSCX'">
      <label>是否主推</label>
      <select class="form-control" name="activitiesProductType" ng-model="activityProduct.activitiesProductType" required="required">
        <option value="04">主推</option>
        <option value="05">非主推</option>
      </select>
    </div>

    <div class="form-group" ng-class="{'has-error':form.activitiesProductType.$invalid}" ng-if="activityProduct.activitiesCode == 'BWCFJH'">
      <label>设置人群</label>
      <select class="form-control" name="activitiesProductType" ng-model="activityProduct.activitiesProductType" ng-options="m.value as m.text for m in dictMap['millionTypeModel']" required="required"> </select>
    </div>

    <div class="form-group" ng-class="{'has-error':form.amount.$invalid}" ng-if="activityProduct.activitiesCode == 'BWCFJH'">
      <label>奖励金额</label>
      <input type="text" class="form-control" placeholder="奖励金额,填写数字" name="amount" ng-model="activityProduct.amount" required="required" only-num>
    </div> 

    <div class="form-group" ng-class="{'has-error':form.beginTime.$invalid}" ng-if="activityProduct.activitiesCode == 'BWCFJH'">
      <label>开始日期</label>
      <input type="date" class="form-control" id="startDateInput" placeholder="开始日期,格式如2015-01-01" name="beginTime" ng-model="activityProduct.beginTimeStr" required="required" maxlength="10" max="9999-99-99" ng-pattern="/^\d{4}-\d{2}-\d{2}$/" ng-if="!id">
      <div class="form-control-text" ng-if="id">{{activityProduct.beginTimeStr}}</div>
    </div>

    <div class="form-group" ng-class="{'has-error':form.endTime.$invalid}" ng-if="activityProduct.activitiesCode == 'BWCFJH'">
      <label>结束日期</label>
      <input type="date" class="form-control" id="endDateInput" placeholder="结束日期,格式如2015-01-01" name="endTime" ng-model="activityProduct.endTimeStr" required="required" maxlength="10" max="9999-99-99" ng-pattern="/^\d{4}-\d{2}-\d{2}$/">
    </div>

    <button type="submit" class="btn btn-primary">添加</button>
  </form> 

  <form class="form-inline search-box" role="form" ng-submit="search()" novalidate>
    <span class="label label-info" style="margin-left: 2px; padding-top: 5px;">查询活动产品</span><br>
    <div class="form-group">
      <input class="form-control" placeholder="产品名称" name="oPName" ng-model="productKw" autocomplete="off"/>
      <!--<ul class="million-product-list" ng-show="showSearchCombox">
        <li ng-repeat="p in products" title="{{p.pName}}" ng-click="selectProduct(p.id,p.pName)">{{p.pName}}</li>
        <li ng-if="loaded && products.length < 1">没有符合条件的产品</li>
      </ul>-->
    </div>
    <div class="form-group">
      <select class="form-control" name="activitiesCode" ng-model="searchMap.activitiesCode" ng-options="m.activitiesCode as m.activitiesName for m in activityListAll" required="required"><option value="">--选择活动--</option></select>
    </div>
    <div class="form-group">
      <select class="form-control" name="activitiesProductType" ng-model="searchMap.activitiesProductType" ng-options="m.value as m.text for m in dictMap['millionTypeModel']" required="required"><option value="">--选择人群--</option></select>
    </div>
    <button type="submit" class="btn btn-default">查询</button>
  </form>

  <table class="table table-striped table-hover">
    <thead>
      <tr>
        <th width="80">ID</th>
        <th width="250">活动名称</th>
        <th width="">产品名称</th>
        <th width="150" ng-show="config.activitiesCode == 'BWCFJH'">产品销售状态</th>
        <th width="150" ng-show="config.activitiesCode == 'BWCFJH'">奖励金额</th>
        <th width="100" ng-show="config.activitiesCode == 'BWCFJH'">开始日期</th>
        <th width="100" ng-show="config.activitiesCode == 'BWCFJH'">结束日期</th>
        <th width="100" ng-show="config.activitiesCode == 'BWCFJH'">人群</th>
        <th width="100" ng-show="config.activitiesCode == 'BWCFJH'">状态</th>
        <th width="60" style="text-align:center">操作</th>
      </tr>
    </thead>
    <tbody>
      <tr ng-repeat="item in list | filter:productKw">
        <td>{{item.activitiesMollionsWealth.id}}</td>
        <td>{{item.activitiesMollionsWealth.activitiesName}}</td>
        
        <td>{{item.product.pName || item.product.jjmc}}</td>

        <td ng-show="config.activitiesCode == 'BWCFJH'">{{item.product.pSaleStatus | productSaleStatusRender}}</td>
        <td ng-show="config.activitiesCode == 'BWCFJH'">{{item.activitiesMollionsWealth.amount | moneyRender}}</td>
        <td ng-show="config.activitiesCode == 'BWCFJH'">{{item.activitiesMollionsWealth.beginTime | date:'yyyy-MM-dd'}}</td>
        <td ng-show="config.activitiesCode == 'BWCFJH'">{{item.activitiesMollionsWealth.endTime | date:'yyyy-MM-dd'}}</td>
        <td ng-show="config.activitiesCode == 'BWCFJH'" class="product-public-status-{{item.activitiesMollionsWealth.activitiesProductType}}">{{item.activitiesMollionsWealth.activitiesProductType | millionTypeRender}}</td>
        <td ng-show="config.activitiesCode == 'BWCFJH'"><span ng-class="{'text-muted':item.activitiesMollionsWealth.status=='3','text-primary':item.activitiesMollionsWealth.status=='1'}">{{item.activitiesMollionsWealth.status | millionStatusRender}}</span></td>
        <td class="optd" style="text-align:center">
          <!--<a href="#/million/edit?id={{item.activitiesMollionsWealth.id}}&&activityCode={{item.activitiesMollionsWealth.activitiesCode}}">编辑</a>-->
          <a class="cur-p" ng-click="remove(item.activitiesMollionsWealth.id)">删除</a>
        </td>
      </tr>
    </tbody>
  </table>

  <div class="pager-box" ng-include src="'tpl/public/pager.html'" ng-show="list.length > 0"></div>
</div>

<div class="layer-box" ng-show="loading">
  <div class="layer-bg"></div>
  <div class="layer-con " style="padding:10px 20px;background: none; color: #fff; font-size: 28px;">
    LOADING...
  </div>
</div> 